<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改文章</title>
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/easyui/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/easyui/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/cms.css" />
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/kindeditor/themes/default/default.css" />
		
	<script type="text/javascript" src="<%=request.getContextPath() %>/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath() %>/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath() %>/easyui/locale/easyui-lang-zh_CN.js"></script>
	<script src="<%=request.getContextPath() %>/kindeditor/kindeditor-min.js"></script>
	<script src="<%=request.getContextPath() %>/kindeditor/lang/zh_CN.js"></script>
	<script type="text/javascript">
	
	var init = {"columnId": '${articleVO.columnId}',
				'title':'${articleVO.title}',
				'id':'${articleVO.id}'};	
	
	
	KindEditor.ready(function(K) {
		window.editor = K.create('textarea[name="content"]', {
			resizeType : 1,
			allowPreviewEmoticons : false,
			allowImageUpload : false,
			items : [
				'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons', 'image', 'link']
		});
	});
	
	
	function submitForm(){
		
		$('#fm').form('submit', {
			url: "<%=request.getContextPath() %>/article/saveEdit.do",
			onSubmit: function(){
				var valid = $(this).form('validate');
				if(valid){
					window.editor.sync();
				}
				return valid;
			},
			success: function(msg){
				if("success" == msg){
		        	window.location = "<%=request.getContextPath() %>/article/view.do?id=${articleVO.id}&edit=true";
		        } else {
		        	$.messager.alert('Warning','<br />' + msg);
		        }
			}
		});

	}
	
	$(function(){
		$("#articleTree").combotree({
			 url:'<%=request.getContextPath() %>/column/articleColumnTree.do',
			 onLoadSuccess:function(node, data){
				 $('#fm').form('load',init);		 
			 }
		});
	});
	</script>
</head>
<body>
	<form id="fm" method="post">
		<input type="hidden" name="id" />
		<table>
			<tr>
				<td class="fm_title">栏目</td>
				<td><select id="articleTree" style="width: 200px;" panelHeight="auto" name="columnId"></select></td>
			</tr>
			<tr>
				<td class="fm_title">标题</td>
				<td>
					<input type='text' name="title" class='easyui-validatebox in-text' 
						style="width: 800px" data-options="required:true" />
				</td>
			</tr>
			<tr>
				<td class="fm_title" valign="top">正文</td>
				<td><textarea rows="20" style="width: 800px" name="content">${articleVO.content}</textarea></td>
			</tr>
			<tr>
				<td colspan="2" align="center" height="40">
					<a href="javascript:submitForm()" class="easyui-linkbutton" iconCls="icon-save">保存</a>&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="<%=request.getContextPath() %>/article/manager.do" class="easyui-linkbutton" iconCls="icon-save">返回</a>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>